import { sysConfigs } from "@/config/api";

const state = {
  isShowTags: null,
  currentActivityId: null,
  iosVerify: null,
  isOpenAgentActivity: null,
  popupNotice: null,
  blindBoxPoint: null,
  minWithdrawMoney: null,
  minTopUpMoney: null,
  exchangeFeeRate: null,
  exchangePointRate: null,
  withdrawFeeRate: null,
  topUpToggle: null
};

const mutations = {
  SET_IS_SHOW_TAGS: (state, isShowTags) => {
    state.isShowTags = isShowTags;
  },
  SET_CURRENT_ACTIVITY_ID: (state, currentActivityId) => {
    state.currentActivityId = currentActivityId;
  },
  SET_IOS_VERIFY: (state, iosVerify) => {
    state.iosVerify = iosVerify;
  },
  SET_IS_OPEN_AGENT_ACTIVITY: (state, isOpenAgentActivity) => {
    state.isOpenAgentActivity = isOpenAgentActivity;
  },
  SET_POPUP_NOTICE: (state, popupNotice) => {
    state.popupNotice = popupNotice
  },
  SET_BLIND_BOX_POINT: (state, blindBoxPoint) => {
    state.blindBoxPoint = blindBoxPoint
  },
  SET_MIN_WITHDRAW_MONEY: (state, minWithdrawMoney) => {
    state.minWithdrawMoney = minWithdrawMoney
  },
  SET_MIN_TOP_UP_MONEY: (state, minTopUpMoney) => {
    state.minTopUpMoney = minTopUpMoney
  },
  SET_EXCHANGE_FEE_RATE:(state, exchangeFeeRate) => {
    state.exchangeFeeRate = exchangeFeeRate
  },
  SET_EXCHANGE_POINT_RATE:(state, exchangePointRate) => {
    state.exchangePointRate = exchangePointRate
  },
  SET_WITHDRAW_FEE_RATE: (state, withdrawFeeRate) => {
    state.withdrawFeeRate = withdrawFeeRate
  },
  SET_TOP_UP_TOGGLE: (state, topUpToggle) => {
    state.topUpToggle = topUpToggle
  }
};

const actions = {
  getSysConfigs({ commit, dispatch }) {
    return new Promise((resolve, reject) => {
      sysConfigs({
        fieldCode: ["isShowTags", "currentActivityId", "isOpenAgentActivity", "popupNotice", "blindBoxPoint", "minWithdrawMoney", "minTopUpMoney", "exchangeFeeRate", "exchangePointRate", "withdrawFeeRate", "topUpToggle", "iosVerify"],
      }).then((res) => {
        commit("SET_IS_SHOW_TAGS", res.isShowTags);
        commit("SET_CURRENT_ACTIVITY_ID", res.currentActivityId);
        commit("SET_IS_OPEN_AGENT_ACTIVITY", res.isOpenAgentActivity);
        commit("SET_POPUP_NOTICE", res.popupNotice);
        commit("SET_BLIND_BOX_POINT", res.blindBoxPoint);
        commit("SET_MIN_WITHDRAW_MONEY", res.minWithdrawMoney)
        commit("SET_MIN_TOP_UP_MONEY", res.minTopUpMoney)
        commit("SET_EXCHANGE_FEE_RATE", res.exchangeFeeRate)
        commit("SET_EXCHANGE_POINT_RATE", res.exchangePointRate)
        commit("SET_WITHDRAW_FEE_RATE", res.withdrawFeeRate)
        commit("SET_TOP_UP_TOGGLE", res.topUpToggle)
		commit("SET_IOS_VERIFY", res.iosVerify)
        resolve(res);
      });
    });
  },
};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
};
